/**
 * Copyright (C)  2011  chen wei hua.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 2.0
 * or any later version published by the Free Software Foundation;
 * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 * A copy of the license is included in the section entitled "GNU Free Documentation License".
 */
package com.javaeye.plan.dto;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.javaeye.common.dto.DTO;

public class InStoreVoucher implements DTO {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6894920169941893269L;
	
	public static final int VOUCHES_STATES_CREATED = 1;
	
	public static final int VOUCHES_STATES_CHECKED = 2;
	
	public static final int VOUCHES_STATES_END = 10;

	private String id;
	
	private Date createDate;
	
	private String deptName;
	
	private int deptId;
	
	private String person;
	
	private int status;
	
	private String removeDetailIds;
	
	private Date updateDate;
	
	private Date checkDate;
	
	private String checkNo;
	
	private String checkResult;
	
	private String checker;
	
	private String checkDescribe;

	private Set<InStoreVoucherDetail> voucherDetails = new HashSet<InStoreVoucherDetail>();

	public void addDetail(InStoreVoucherDetail detail) {
		detail.setVoucher(this);
		voucherDetails.add(detail);
	}
	
	public List<Integer> getRemoveDetailIdList() {
		List<Integer> ret = new ArrayList<Integer>();
		if (removeDetailIds != null && !"".equals(removeDetailIds.trim()) ) {
			String[] deleteIds = removeDetailIds.split(",");
			for (String deleteId : deleteIds) {
				if (!"".equals(deleteId)) {
					ret.add(new Integer(deleteId));
				}
			}
		}
		return ret;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	public int getDeptId() {
		return deptId;
	}

	public void setDeptId(int deptId) {
		this.deptId = deptId;
	}

	public String getPerson() {
		return person;
	}

	public void setPerson(String person) {
		this.person = person;
	}

	public int getStatus() {
		return status;
	}
	
	public String getStatusName() {
		switch (status) {
		case VOUCHES_STATES_CREATED :
			return "等待检验";
		case VOUCHES_STATES_CHECKED :
			return "等待入库";
		case VOUCHES_STATES_END :
			return "已经入库";
		default :
			return "";
		}
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Set<InStoreVoucherDetail> getVoucherDetails() {
		return voucherDetails;
	}

	public void setVoucherDetails(Set<InStoreVoucherDetail> voucherDetails) {
		this.voucherDetails = voucherDetails;
	}

	public void setRemoveDetailIds(String removeDetailIds) {
		this.removeDetailIds = removeDetailIds;
	}

	public String getRemoveDetailIds() {
		return removeDetailIds;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	public String getCheckNo() {
		return checkNo;
	}

	public void setCheckNo(String checkNo) {
		this.checkNo = checkNo;
	}

	public String getCheckResult() {
		if (null == checkResult || "".equals(checkResult.trim())) {
			return "合格";
		}
		return checkResult;
	}

	public void setCheckResult(String checkResult) {
		this.checkResult = checkResult;
	}

	public String getChecker() {
		return checker;
	}

	public void setChecker(String checker) {
		this.checker = checker;
	}

	public String getCheckDescribe() {
		return checkDescribe;
	}

	public void setCheckDescribe(String checkDescribe) {
		this.checkDescribe = checkDescribe;
	}
	
}
